# -*- coding:UTF-8 -*-
import os
import importlib
from src.appsvrapi import AppServerApi, APIReservation, APIBase
import logging

__author__ = 'raptor'

__doc__ = """

"""

basedir = os.path.abspath(os.path.dirname(__file__))


class Config:
    def __init__(self):
        pass

    SECRET_KEY = '123456'

    HOSPITAL = "东昌府区妇幼保健院"
    API_URL = "http://10.2.7.139"  # 报到接口
    WSDL = "http://10.2.12.34:9004/ESB.asmx?wsdl"  # 列表接口

    API_RESERVATION = "http://10.2.7.139:9012/api"  # 预约接口
    OPERATORID = "9021"
    OPERATORNAME = "海鹚大众"
    LOG_FILEPATH = '/var/www/log/cqzl-dev.log'

    REPORT_CACHE_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                                     'report_cache')

    @staticmethod
    def init_app(app):
        AppServerApi.API_URL = app.config['API_URL']
        AppServerApi.HOSPITAL = app.config['HOSPITAL']
        # APIBase.API_URL = app.config['API_SMS']
        APIReservation.API_URL = app.config['API_RESERVATION']


class DevelopmentConfig(Config):
    DEBUG = True


class ProductionConfig(Config):
    """
    正式
    """


if os.path.exists("/var/www/work"):
    config = {
        'development': DevelopmentConfig,
        'production': ProductionConfig,
        'default': ProductionConfig
    }
    try:
        import production as prod


        class Prod(prod.Production, ProductionConfig):
            pass


        config['default'] = Prod
    except ImportError:
        import traceback

        logging.error(traceback.format_exc())
else:
    config = {
        'development': DevelopmentConfig,
        'production': ProductionConfig,
        'default': DevelopmentConfig
    }
